//
//  BaseTableViewController.swift
//  Sina
//
//  Created by 王杰 on 15/11/8.
//  Copyright © 2015年 王杰. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController,VisitorLoginViewDelegate {

    //添加用户是否登录标记
    var userLogin = UserAccountViewModel().userLogin
    var visitorLoginView: VisitorLoginView?
    override func loadView() {
        
        userLogin ? super.loadView() : loadVisitorView()
    }
    
    private func loadVisitorView() {
        //view的大小  在 viewDidLoad就会设置
        visitorLoginView = VisitorLoginView()
        //设置代理
        visitorLoginView?.visitorDelegate = self
        view = visitorLoginView
        
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "visitorWillRegister")
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登陆", style: .Plain, target: self, action: "visitorWillLogin")
        
    }
    
    //MARK:visitorDelegate 协议方法
    func visitorWillRegister() {
        print("come on")
    }
    
    func visitorWillLogin() {
        print("come in")
        let oauth = OAuthViewController()
        let nav = UINavigationController(rootViewController: oauth)
        presentViewController(nav, animated: true, completion: nil)
    }
    

    override func viewDidLoad() {
        super.viewDidLoad()
        
        
    }

}
